<div class="panel panel-default">
	<div class="panel-heading">
		<?php 
		$this->widget('zii.widgets.CBreadcrumbs',array(
			'links'=>array(
				'后台管理',
				'Tags列表'
			)
		));
		?>
	</div>
	<div class="panel-body">
		<p class="text-right">
			<a href="<?php echo $this->createUrl('add');?>" class="btn btn-primary">添加Tag</a>
		</p>
		<?php if(!empty($tags)):?>
		<table class="table table-default">
			<thead>
				<tr>
					<th>Tags ID</th>
					<th>Tags名称</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<?php foreach($tags as $v):?>
				<tr>
					<td><?php echo $v['tags_id'];?></td>
					<td><?php echo $v['tags_name'];?></td>
					<td>
						<a href="<?php echo $this->createUrl('edit', array('tagsId'=>$v['tags_id']));?>">编辑</a>
						<a class="delete" tagsId="<?php echo $v['tags_id']; ?>" href="<?php echo $this->createUrl('delete');?>">删除</a>
					</td>
				</tr>
				<?php endforeach;?>
			</tbody>
		</table>
		<?php else:?>
		没有记录
		<?php endif;?>
	</div>
</div>
<script>
	$(function(){
		$('.delete').click(function(){
			var $this = $(this);
			if(!confirm("确定要删除吗？")){
				return false;
				}
			$.ajax({
				method : 'post',
				url : $this.attr('href'),
				data : {'tagsId' : $this.attr('tagsId')},
				success : function(data){
					data = eval("("+data+")");
					if(data.code == 1){
						$this.parents('tr').remove();
						} else {
						alert('删除失败');
							}
					}
				});
			return false;
			});
	
		});
</script>